<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>unitIndex</title>

    <!-- Bootstrap -->
    <link rel="stylesheet" href="../commons/bootstrap-3.3.7-dist/css/bootstrap.min.css">
    <!-- 加载bootstrap-select -->
    <link href="../commons/bootstrap-select-1.13.9-dist/css/bootstrap-select.min.css" rel="stylesheet">
    <!-- 加载bootstrap-treeview -->
    <link href="../commons/bootstrap-treeview-1.2.0-dist/bootstrap-treeview.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../commons/css/currency.css">



    <!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
    <!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-navbar-collapse">
                <span class="sr-only">切换导航</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">CIMS-校园即时通讯系统</a>
        </div>
        <div class="collapse navbar-collapse" id="example-navbar-collapse">
            <ul class="nav navbar-nav navbar-left">
                <li class="active"><a href="unitIndex"> 首页</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false"> 单位管理<span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="unitTypeManager"> 单位类型</a></li>
                        <li><a href="unitManager"> 单位设置</a></li>
                    </ul>
                </li>
                <li><a href="userManager"> 用户管理</a></li>
            </ul>
            <ul class="nav navbar-nav" style="float: right">
                <li class=""><a id="loginUser_nav">管理员：</a></li>
                <li class=""><a id="logout_nav">注销</a></li>
            </ul>
        </div>
    </div>
</nav>

<div class="container">
    <div class="jumbotron jumbotron-fluid" style="position: relative;margin-top: 0px;height: 500px;">
        <h1>
            <small class="text-muted">杭州职业技术学院</small>即时通系统管理平台
        </h1>
        <div class=" chart-container col-xs-6 col-md-3">
            <p class="lead">接入单位：</p>
            <small class="text-muted" id="unitCount">10个</small>
            <p class="lead">使用用户：</p>
            <small class="text-muted" id="userCount">10000个</small>
        </div>

        <div class="col-md-6">
            <canvas id="myChart"></canvas>
        </div>

    </div>

</div>

<div class="footer ">
    <div class="container">
        <div class="row footer-bottom">
            <ul class="list-inline text-center">
                <li> Campus Instant Messaging System @2020 杭州职业技术学院 软件技术专业</li>
            </ul>
        </div>
    </div>
</div>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script src="../commons/js/jquery.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="../commons/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script src="../commons/bootstrap-treeview-1.2.0-dist/bootstrap-treeview.min.js"></script>
<script src="../commons/bootstrap-select-1.13.9-dist/js/bootstrap-select.min.js"></script>
<!--加载chart.js -->
<script src="../commons/Chart.js-2.9.3/dist/Chart.min.js"></script>

<script src="../commons/js/login.js"></script>
<script src="../commons/Chart.js-2.9.3/dist/Chart.min.js"></script>
<script src="../commons/Chart.js-2.9.3/samples/utils.js"></script>
<script>
    $(function () {
        $.ajax({
            url: "unitCount",
            type: "get",
            dataType: "json",
            success: function (result) {
                if (result.code == 100) {
                    $("#unitCount").html(result.extend.unitCount);
                    $("#userCount").html(result.extend.userCount);

                    initMyChart(result);
                }
            }
        });
    });

    function initMyChart(result) {
        var ctx = document.getElementById('myChart').getContext('2d');
        var chart = new Chart(ctx, {
            type: 'bar',

            data: {
                datasets: [{
                    data: result.extend.allCounts,
                    backgroundColor:
                    window.chartColors.red
                    ,
                    label: '发送消息总量'
                },
                    {
                        data: result.extend.doneCounts,
                        backgroundColor:
                        window.chartColors.blue
                        ,
                        label: '已处理消息量'
                    }],
                labels:result.extend.labels
            },

            options: {
                responsive: true,
                legend: {
                    position: 'right',
                },
                title: {
                    display: true,
                    text: '月发送消息统计图'
                },
                animation: {
                    animateScale: true,
                    animateRotate: true
                },
                scales: {
                    yAxes: [{
                        ticks: {
                            beginAtZero:true
                        }
                    }]
                }
            }
        });
    }
</script>

<script>

</script>
</body>
</html>
